package com.wxp.demo09.util;

import android.telephony.TelephonyManager;

/**
 * 网络工具类
 */
public class NetworkUtil {

    private NetworkUtil() {
    }

    /**
     * 获取数据连接的制式类型
     *
     * @param subType 类型标识
     * @return 数据连接的制式类型
     */
    public static String getNetworkClass(int subType) {
        return switch (subType) {
            case TelephonyManager.NETWORK_TYPE_GPRS, TelephonyManager.NETWORK_TYPE_EDGE,
                 TelephonyManager.NETWORK_TYPE_CDMA, TelephonyManager.NETWORK_TYPE_1xRTT,
                 TelephonyManager.NETWORK_TYPE_IDEN -> "2G";
            case TelephonyManager.NETWORK_TYPE_UMTS, TelephonyManager.NETWORK_TYPE_EVDO_0,
                 TelephonyManager.NETWORK_TYPE_EVDO_A, TelephonyManager.NETWORK_TYPE_HSDPA,
                 TelephonyManager.NETWORK_TYPE_HSUPA, TelephonyManager.NETWORK_TYPE_HSPA,
                 TelephonyManager.NETWORK_TYPE_EVDO_B, TelephonyManager.NETWORK_TYPE_EHRPD,
                 TelephonyManager.NETWORK_TYPE_HSPAP -> "3G";
            case TelephonyManager.NETWORK_TYPE_LTE -> "4G";
            case TelephonyManager.NETWORK_TYPE_NR -> "5G";
            default -> "未知";
        };
    }

}
